package com.jxnu.duewang.zmly.zmly.fragment;


import android.os.Bundle;
import com.google.android.material.tabs.TabLayout;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jxnu.duewang.zmly.R;
import com.jxnu.duewang.zmly.zmly.adapter.DownloadAdapter;

import java.util.ArrayList;
import java.util.List;

import liyuxian.fragment.fragment.DownFragment;
import liyuxian.fragment.fragment.SpecialkFragment;
import liyuxian.fragment.fragment.VoiceFragment;

/**
 * A simple {@link Fragment} subclass.
 */
public class DownloadFragment extends Fragment {
    private List<String> string;
    private List<Fragment> list;

    private ViewPager viewPagerDown;
    private DownFragment downFragment;
    private SpecialkFragment specialkFragment;
    private VoiceFragment voiceFragment;
    private TabLayout tabldown;

    public DownloadFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_download, container, false);
        init(rootView);
        return rootView;
    }

    private void init(View rootView) {
        tabldown = (TabLayout) rootView.findViewById(R.id.tab_downlodad);
        viewPagerDown = (ViewPager) rootView.findViewById(R.id.viewpager_download);
        downFragment = new DownFragment();
        specialkFragment = new SpecialkFragment();
        voiceFragment = new VoiceFragment();

        list = new ArrayList<>();
        list.add(specialkFragment);
        list.add(voiceFragment);
        list.add(downFragment);

       string = new ArrayList<>();

        string.add("专辑");
        string.add("声音");
        string.add("下载中");
        viewPagerDown.setAdapter(new DownloadAdapter(getChildFragmentManager(),string,list));
        tabldown.setupWithViewPager(viewPagerDown);

    }

}
